// 腾讯地图地点搜索工具类
const config = require(`../config.js`);
//cityName，城市名
//keyword，搜索关键字
//filter，过滤分类
//callback，回调函数，返回搜索pois
// 其他具体参数查看http://lbs.qq.com/webservice_v1/guide-search.html#filter_detail
//$page_size=20这个属性别加，加了会出错，我也不知道为什么！默认10条
function showSearchPois(cityName, keyword,filter,callback) {
  let mapApiUrl = `https://apis.map.qq.com/ws/place/v1/search?boundary=region(${cityName},0)&keyword=${keyword}&orderby=_distance&key=${config.mapSecret}&filter=category=${filter}&page_index=1`;
  wx.request({
    url: mapApiUrl,
    data: {},
    method: `GET`,
    success: (res) => {
      callback(res.data.data)
    }
  })
}

module.exports = {
  showSearchPois: showSearchPois
}